<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE);

function randomChar($length = 8) 
{ 
    $pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ';
    $key = '';
    for($i=0;$i<$length;$i++) 
    { 
        $key .= $pattern{mt_rand(0,strlen($pattern) - 1)};    //生成php随机数 
    } 
    return $key; 
} 
?>